﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.Contracts;
using TaskManager.Domain.Repositories;

namespace TaskManager.Domain.BusinessObjects
{
    /// <summary>
    /// Log entry
    /// </summary>
    public class LogEntry : IEntity<int>
    {
        /// <summary>
        /// Log entry unique identifier
        /// </summary>
        [Key]
        public int Id { get; set; }
        
        /// <summary>
        /// User who modified the task 
        /// </summary>
        public string User { get; set; }

        /// <summary>
        /// Message
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// Date and time of creation
        /// </summary>
        public DateTime Created { get; set; }

        /// <summary>
        /// Parameterless constructor
        /// </summary>
        public LogEntry()
        {
            
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="user">User who modified task</param>
        /// <param name="message">Message</param>
        public LogEntry(User user, string message)
        {
            Contract.Requires(user != null);
            Contract.Requires(!string.IsNullOrEmpty(message));

            User = user.Name;
            Message = message;
            Created = DateTime.Now;
        }
    }
}